package cn.edu.jxust.core.infrastructure.mqtt.runner;

import cn.edu.jxust.core.infrastructure.mqtt.MqClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;

/**
 * @author liuguangyun
 * @version 1.0
 * @description 统启动时连接Onenet自动订阅
 * @since 2020/07/07 15:10
 */

@Slf4j
@Order(value = 2)
@Component
public class MqttRunner implements ApplicationRunner {

    @Resource
    private MqClient mqClient;

    /**
     * Mqtt 启动类
     * @param args 参数
     */
    @Override
    public void run(ApplicationArguments args) {

        boolean connect = mqClient.connect();
        if(connect){
            log.info("Mqtt 订阅消息队列服务正在接收数据...");
        }else{
            log.error("MqttRunner --> run 异常...");
        }

    }
}
